Network Connectivity Check: A Guide to Using the ping Command in Ubuntu

In Ubuntu, `ping` is a fundamental tool for troubleshooting network connectivity. It sends packets based on the ICMP protocol to a target host and receives responses to determine if the link is operational and if the target is reachable. The basic syntax is `ping [options] target_address`, where the target address supports either an IP or a domain name. Common options include: - `-c <count>`: Specify the number of packets to send (e.g., `ping -c 4 www.baidu.com` tests 4 times). - `-t`: Continuously ping until manually interrupted (`Ctrl+C`). - `-i <interval>`: Set the sending interval (e.g., `-i 0.5` shortens to 0.5 seconds per packet). - `-W <timeout>`: Set the timeout period (e.g., `-W 2` waits 2 seconds). - `-s <size>`: Adjust the packet size (e.g., `-s 1024` sends 1024-byte packets). Application scenarios include: - Checking local network connectivity (`ping -c 1 127.0.0.1` to verify the protocol stack). - Testing local area network (LAN) devices (ping the gateway or IPs in the same subnet). - Verifying external network access (ping Baidu/Google DNS servers). Common issues and solutions: - "Host unreachable": Check the target IP, host status, or firewall settings.

Read More